package utils

import (
	"math/rand"
	"time"
)

// 生成随机字符串, 变量为字符串长度
func RandomString(n int) string {
	if n <= 0 || n > 32 {
		n = 32
	}
	var letters = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")
	result := make([]byte, n)
	rand.Seed(time.Now().UnixNano())
	for i := range result {
		result[i] = letters[rand.Intn(len(letters))]
	}
	return string(result)
}
